import pymysql

database = "Prac"

connection = pymysql.connect(
    host = 'localhost',
    user = 'root',
    password= 'cpy50686868cpy',
    database= database,
    charset= 'utf8mb4'
)
c = connection.cursor()
c.execute('select * from medicine;')
numrows = c.rowcount

# for x in range(numrows):
#     row = c.fetchone()
#     # print(row)

# rows = c.fetchmany(3)

rows = c.fetchall()
print(rows)

# c.execute('insert into medicine (mname,registerdate,des,youxiao) values ("板蓝根2","2009-03-06","治疗xxx","1")')
# connection.commit()
# print(c.lastrowid)

# c.execute('select * from medicine;')
# rows = c.fetchall()
# print(rows)


mid = input('请输入要查询的药品的ID:')
c.execute(f'select * from medicine where mid = {mid}')
print(c.fetchall())

